<?php

/**
 * Marque form.
 *
 * @package    emc
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class MarqueForm extends BaseMarqueForm
{
  public function configure()
  {
  	$this->setWidgets(array(
			'name'					=>		new sfWidgetFormInput(),
			'jobboard_id'			=>		new sfWidgetFormSelect(array('choices' => $this->getJobboardList())),
			'description'			=>		new sfWidgetFormTextarea(),
			'little_logo'			=>		new sfWidgetFormInput(),
			'logo'					=>		new sfWidgetFormInput(),
			'cover_picture'			=>		new sfWidgetFormInput(),
			'href'					=>		new sfWidgetFormInput(),
			'is_full_import'		=>		new sfWidgetFormInputCheckbox(),	
			'is_active'				=>		new sfWidgetFormInputCheckbox(),
		));
				
		$this->widgetSchema->setNameFormat('marque[%s]');
		$this->widgetSchema->setLabels(array(
			'name'					=>		'Tên',
			'jobboard_id'			=>		'Website',
			'description'			=>		'Mô tả',
			'little_logo'			=>		'Logo nhỏ',
			'logo'					=>		'Logo',
			'cover_picture'			=>		'Hình nền',
			'href'					=>		'Link',
			'is_full_import'		=>		'Đã lấy hết sản phẩm',	
			'is_active'				=>		'Khả dụng',
		));
  }


  private function getJobboardList()
  {
  	$q = Doctrine_Query::create()
  			->select('j.id, j.name')
  			->from('Jobboard j');
  	$results = $q->fetchArray();
  	$jobboards = array();
  	foreach ($results as $result)
  		$jobboards[$result['id']] = $result['name'];
  	return $jobboards;
  }
}
